package com.tungse.study.io.one;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

public class Client {

    public static void main(String[] args) throws IOException {
        //1 创建 socket对象 请求服务端的链接
        Socket socket = new Socket("127.0.0.1", 9999);
        //2 从socket对象中获取输入流和输出流
        OutputStream os = socket.getOutputStream();
        //3 把字节输出流包装成一个打印流
        PrintStream ps = new PrintStream(os);

        ps.println("我是客户端，我已经连接上服务器了");
        ps.flush();//刷新缓冲区

    }
}
